/**
 * 
 */
package com.upload.action;

import java.io.File;

import org.whatisjava.action.BaseAction;

/**
 * 文件上传
 * 
 * @author Wangpeihu
 * @team [Never give up]
 * @since JDK1.6(建议)
 * @date 2010-2-2
 */

public class FileUploadAction extends BaseAction {

	// 该名要与表单的名字对应
	private File photo;

	// 必须按照这个格式 [表单的名字＋FileName]_[photoFileName]
	private String photoFileName;

	public File getPhoto() {
		return photo;
	}

	public void setPhoto(File photo) {
		this.photo = photo;
	}

	/**
	 * 显示页面
	 * 
	 * @return
	 */
	public String showForm() {
		return "success";
	}

	/**
	 * @return
	 */
	public String execute() {
		String path = "upload";
		path = application.getRealPath(path);
		photo.renameTo(new File(path, photoFileName));
		return "success";
	}
}
